package com.akeil.flash.utils;

import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class ShowToolBarText extends ContributionItem {

	@Override
	public void fill(ToolBar parent, int index) {
		ToolItem[] toolItems = parent.getItems();
		for(ToolItem toolItem : toolItems){
			ActionContributionItem contributionItem = (ActionContributionItem)toolItem.getData();
			contributionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT); 
			
			IAction action = contributionItem.getAction();
			if(toolItem.getText() == null || toolItem.getText().length() == 0){
				toolItem.setText(action.getText());
			}
		}
	}

}